package demo;

import javax.swing.*;
import java.util.Arrays;

public class Test {
    public static void sort(Student[] students) {
        for (int i = 0; i < students.length - 1; i++) {
            for (int j = 0; j < students.length - 1 - i; j++) {
                if (students[j].compareTo(students[j+1]) > 0){
                    Student temp = students[j];
                    students[j] = students[j + 1];
                    students[j + 1] = temp;
                }
            }
        }
    }

    public static void main(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student("zhansgan", 85);
        students[1] = new Student("lisi", 70);
        students[2] = new Student("wangwu", 90);
        System.out.println(Arrays.toString(students));
        sort(students);
        System.out.println(Arrays.toString(students));
    }
}
